#include "./TDDNS.h"

TDDNS::TDDNS() {}
TDDNS::~TDDNS() {}

void TDDNS::client(I_TDDNS_Client *client)
{
    ddns_client = client;
}

void TDDNS::update()
{
    String currentIp = ddns_client->getCurrentIp();
    Serial.println("TDDNS::update   currentIP is " + currentIp);
    bool isNeedChangeRecord = ddns_client->isNeedChange(currentIp, old_ip);
    if (isNeedChangeRecord)
    {
        Serial.println("TDDNS::update   need to update ");

        ddns_client->updateRecord(currentIp);
    }
    else
    {
        Serial.println("TDDNS::update   no need to update");
    }
}
